package module.building.view.buildingTips
{
	import com.darwin.darwinUI.controls.Label;
	import com.darwin.darwinUI.core.UIComponent;
	import com.darwin.darwinUI.general.DarwinFont;
	import com.greensock.TweenAlign;
	import com.greensock.TweenLite;
	
	import flash.events.Event;
	
	import module.main.view.ResourceConst;

	public class BuildingResourceTips extends UIComponent
	{
		private var label:Label;
		private var _tipString:String;
		
		public function BuildingResourceTips(tip:String)
		{
			_tipString = tip;
			init();
			initData();
			addEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		
		private function init():void
		{
//			this.backgroundSkin = ResourceConst.GENERAL_IMAGE_TIPS_BG;
			
			var font:DarwinFont = new DarwinFont("",30);
			label = new Label(_tipString,font);
			label.textColor = 0xff0000;
			addChild(label);
		}
		
		private function initData():void
		{			
			width = 200;
			height = 50;
			
			label.x = (width - label.textWidth)/2;
			label.y = (height - label.textHeight)/2;
		}
		
		private function onAdded(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAdded);
//			var currentY:int = this.y;
			
//			var tween:TweenLite = new TweenLite(this,2,{y:50,alpha:0});
//			tween.play();
			
			TweenLite.to(this,0.6,{y:50,onComplete:onMoveFinish});
		}
		
		private function onMoveFinish():void
		{
			TweenLite.to(this,0.6,{y:0,alpha:0});
		}
	}
}